//
//  BaseViewController.m
//  Dear
//
//  Created by 陈俊俊 on 15/7/11.
//  Copyright (c) 2015年 陈俊俊. All rights reserved.
//

#import "BaseViewController.h"

@implementation BaseViewController
- (void)viewDidLoad{
    [super viewDidLoad];
    self.view.backgroundColor = HexColor(@"f6f7f7");
    if(IOS7) {
         self.edgesForExtendedLayout = UIRectEdgeNone;
         self.extendedLayoutIncludesOpaqueBars = NO;
         self.modalPresentationCapturesStatusBarAppearance = NO;
     }
    //设置导航条上的选项按钮的颜色
    self.navigationController.navigationBar.barTintColor= RGBA(39, 212, 91, 1);
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    //设置导航条的返回按钮
    self.navigationItem.backBarButtonItem=[self setBackBarButtonItem];
}
//设置导航条的返回按钮，在视图控制器即将消失的时候设置
- (UIBarButtonItem *)setBackBarButtonItem{
    UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] init];
    backButtonItem.title = @"返回";
    return backButtonItem;
}
#pragma mark - 添加titleView
- (void)createTitleViewWith:(NSString *)title
{
    //创建一个label
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 40)];
    label.text = title;
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont boldSystemFontOfSize:18];
    label.textAlignment = NSTextAlignmentCenter;
    //作为导航条的标题视图
    //属于当前视图控制器的
    self.navigationItem.titleView = label;
}
#pragma mark - 收键盘

//收键盘操作
- (void)keyboardHidden{
}

//当点击屏幕空白处的时候，收键盘
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
    [self keyboardHidden];
}

//当点击键盘的return键的时候，收键盘
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [self keyboardHidden];
    return YES;
}

@end
